"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.StartAction = void 0;
const chalk_1 = require("chalk");
const abstract_action_1 = require("./abstract.action");
const startScript = require('cpaas-webpack-scripts/scripts/start').default;
const ui_1 = require("../lib/ui");
class StartAction extends abstract_action_1.AbstractAction {
    handle(inputs, options) {
        var _a;
        return __awaiter(this, void 0, void 0, function* () {
            try {
                yield startScript({
                    packageName: (_a = inputs.find((item) => item.name === 'app')) === null || _a === void 0 ? void 0 : _a.value,
                });
            }
            catch (err) {
                if (err instanceof Error) {
                    console.log(`\n${ui_1.ERROR_PREFIX} ${err.message}\n`);
                    console.log(err);
                }
                else {
                    console.error(`\n${chalk_1.default.red(err)}\n`);
                    console.log(err);
                }
                process.exit(1);
            }
        });
    }
}
exports.StartAction = StartAction;
